<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="iso-8859-1" %>
<%@ include file="include.jsp" %>

<%--
PARAMETERS
  coverArtId: ID of Media Element.
  coverArtSize: Height and width of cover art.
  coverArtCaption: Media Element name to display as caption.
  showLink: Whether to make the cover art image link to the Media Element page.
  showZoom: Whether to display a link for zooming the cover art.
  showCaption: Whether to display the given caption below the image.
  appearAfter: Fade in after this many milliseconds, or nil if no fading in should happen.
--%>
<c:choose>
    <c:when test="${empty param.coverArtSize}">
        <c:set var="size" value="auto"/>
    </c:when>
    <c:otherwise>
        <c:set var="size" value="${param.coverArtSize + 8}px"/>
    </c:otherwise>
</c:choose>

<c:set var="opacity" value="${empty param.appearAfter ? 1 : 0}"/>

<div style="width:${size}; max-width:${size}; height:${size}; max-height:${size}" title="${param.coverArtCaption}">
    <c:url value="main.view" var="mainUrl">
        <c:param name="id" value="${param.coverArtId}"/>
    </c:url>

    <c:url value="/coverArt.view" var="coverArtUrl">
        <c:if test="${not empty param.coverArtSize}">
            <c:param name="size" value="${param.coverArtSize}"/>
        </c:if>
        <c:param name="id" value="${param.coverArtId}"/>
    </c:url>
    <c:url value="/coverArt.view" var="zoomCoverArtUrl">
        <c:param name="id" value="${param.coverArtId}"/>
    </c:url>

    <str:randomString count="5" type="alphabet" var="divId"/>
    <div class="outerpair1" id="${divId}" style="display:none">
        <div class="outerpair2">
            <div class="shadowbox">
                <div class="innerbox">
                    <c:choose>
                        <c:when test="${param.showLink}"><a href="${mainUrl}" title="${param.coverArtCaption}"></c:when>
                            <c:when test="${param.showZoom}"><a href="${zoomCoverArtUrl}" rel="zoom" title="${param.coverArtCaption}"></c:when>
                            </c:choose>
                            <img src="${coverArtUrl}" alt="${param.coverArtCaption}">
                            <c:if test="${param.showLink or param.showZoom}"></a></c:if>
                    </div>
                </div>
            </div>
        </div>
    <c:if test="${not empty param.appearAfter}">
        <script type="text/javascript">
            $(document).ready(function() {
                setTimeout("$('#${divId}').fadeIn(500)", ${param.appearAfter});
            });
        </script>
    </c:if>
</div>